<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj1 = {
            'key': 'zzk',
            'value': {
                'pair1': '111',
                'pair2': '222'
            }
        }
        let obj2 = deepClone(obj1);
        obj1.key = 'zzk1';
        console.log('obj1', obj1);
        console.log('obj2', obj2);
        obj1.value.pair1 = '呱呱嘎';
        console.log('obj1', obj1);
        console.log('obj2', obj2);
        function deepClone(obj) {
            if (typeof obj !== 'object') return;
            var newObj = obj instanceof Array ? [] : {};
            for (var key in obj) {
                if (obj.hasOwnProperty(key)) {
                    newObj[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key];
                }
            }
            return newObj;
        }

    </script>
</body>

</html>